import { GCellRenderer } from "../../../../../com/mui/controls/GCellRenderer";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { ObjCreate } from "../../common/ObjCreate";
import { Language } from "../../../../../extend/language/Language";
import { SGuildCallTogether } from "../../../../../Message/Game/SGuildCallTogether";
import { EGuildPosition } from "../../../../../Message/Game/EGuildPosition";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { SceneConfig } from "../../../resource/SceneConfig";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { DataEvent } from "../../../events/DataEvent";
import { GModuleEvent } from "../../../mvc/GModuleEvent";
import { GButton } from "../../../../../com/mui/controls/GButton";
type int = number;
//class GuildCallerRenderer
    
    export  class GuildCallerRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            this.mouseChildren = true;
            this.mouseEnabled = true;
            this.initUI();
            return;
        }

        /* internal  */initUI(): void
        {
            var loc1=new GTextFormat(FontUtil.songtiName, 12, 11661311);
            loc1.leading = 5;
            this._tfTips = ObjCreate.createTextField("", 0, 0, 260, 36, this, loc1);
            this._tfTips.wordWrap = true;
            this._tfTips.multiline = true;
            this._tfTips.mouseEnabled = false;
            this._btnFly = ObjCreate.createGButton(Language.getString(60754), 280, 4, 70, 26, this, "ButtonLarge");
            this._btnFly.enabled = true;
            this._btnFly.drawNow();
            this._btnFly.addEventListener(flash.events.MouseEvent.CLICK, this.onFlyBtnClick);
            ObjCreate.createBg(0, 36, 356, 2, this, "SplitLine");
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=null;
            var loc5=null;
            super.data = arg1;
            this._callerInfo = arg1 as SGuildCallTogether;
            if (typeof arg1 === "sguildcalltogether") 
            {
                loc1 = "";
                if (this._callerInfo.fromPlayer.position != EGuildPosition._EGuildMember) 
                {
                    loc1 = GameDefConfig.instance.getPositionName(this._callerInfo.fromPlayer.position);
                }
                else 
                {
                    loc1 = Language.getString(60759);
                }
                loc2 = HTMLUtil.addColor(loc1, this.getPositionColor(this._callerInfo.fromPlayer.position));
                loc3 = SceneConfig.instance.getSceneInfo(this._callerInfo.fromPos.map).sMapDefine.name;
                loc4 = HTMLUtil.addColor(loc3 + "（" + this._callerInfo.fromPos.x + "，" + this._callerInfo.fromPos.y + "）", GlobalStyle.color4);
                loc5 = Language.getStringByParam(60756, loc2, HTMLUtil.addColor(this._callerInfo.fromPlayer.miniPlayer.name, "#FFFF00"), loc4);
                this._tfTips.htmlText = loc5;
            }
            return;
        }

        /* internal  */getPositionColor(arg1: int): string
        {
            var loc1="";
            if (arg1 != EGuildPosition._EGuildLeader) 
            {
                if (arg1 != EGuildPosition._EGuildDeputyLeader) 
                {
                    if (arg1 != EGuildPosition._EGuildPresbyter) 
                    {
                        loc1 = "#ffffff";
                    }
                    else 
                    {
                        loc1 = "#00FF00";
                    }
                }
                else 
                {
                    loc1 = "#00BEFF";
                }
            }
            else 
            {
                loc1 = "#ff00ff";
            }
            return loc1;
        }

        /* internal  */onFlyBtnClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.dispatchEvent(new DataEvent(GModuleEvent.Guild_CallTogetherFly, this._callerInfo, false, true, true));
            return;
        }

        /* internal */ /* var */_tfTips: Object /* flash.text.TextField */;

        /* internal */ /* var */_btnFly: GButton;

        /* internal */ /* var */_callerInfo: SGuildCallTogether;
    }
